home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Packmags
/
NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].zip
/
NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].adf
/
doc
/
loader.doc
< prev
next >
Wrap
Text File
|
1988-01-19
|
5KB
|
104 lines
Libraries
by ROGER from VIRUS.
The source-file that I'll be explaining about is the simplified loader
from my startupcoder. It's function is simple and so is the source.
The source opends the dos.library,then it runs the execute command
(don't mix it up with your CLI execute command),that
will load/run the files mentioned at the 'command1' label,then the
dos.library is closed and thats all.Extremely simple.This source just
shows the usage of the 'openlibrary' command and how you should use
library commands from assembler.Many people who just started assembler
seem to have many problems in opening & using libraries.
A library is nothing more than a bunch of routines in your ROM
that make life easier (sometimes).One of these libraries is the Dos.library
this library contains all the thing you need to handle the DOS.
The source shows how powerfull one library command can be.The execute
command needs some info before you use it.
D1 the adress of the command(s) that you wish to execute
D2 Filehandle of window for extra data,usualy 0
D3 Windowhandle,can be achieved by opening a dos window
if you want to execute in the standard CLI window
then this is 0
A6 Dosbase,standard when calling a Dos.library command.
The dosbase is saved in D0 when you open a library.
Then it's stored in a longword (8 bytes) with the label
'Dosbase'.
But before you can use the execute command you must open the dos.library.
This can be done with the Openlibrary command that can be found in the
Exec.library.To use a library command you must know the base of the
library.The execbase is always 4 (At the top of the source you can find
'Execbase = 4' -this is to make your life easier.The Amiga knows
thousands of these prefix numbers).
The Openlibrary command must also have a pointer at the name of the library
,simply move 'Dosname' to A1 and make a label called Dosname: and
Dc.b "Dos.library" (this puts the data Dos.library at the label 'dosname'
in your memory).
Then do 'jsr openlibrary(a6)'.Again,at the top of the source is
'Openlibrary = -408' for your convenience.
I know this all sounds pretty complicated when you're just starting,but
once you'll get used to the libraries,they work really well.
One thing about the 'Command1' label where the commands are listed:
In the startupcoder the files will be loaded automaticly.In the
source,you get the honour of naming the files...
If you want to load/run more than one file,simply do this:
Command1:
dc.b "intro",$0a ;$0a means RETURN
dc.b "stack 50000",$0a
dc.b "show picture",$0a
dc.b 00 ;00 is end of commands
Now let's look at the start of the source:
----------------------------------------------
Opendoslibrary:
move.l execbase,a6
lea dosname,a1
jsr openlib(a6)
move.l d0,dosbase
----------------------------------------------
This opens the dos.library.
In the dos-library at offset -222 is the execute-command.
The Dos-Execute command loads and executes files
----------------------------------------------
executer: move.l #command1,d1 ;move command in d1
move.l dosbase,a6 ;dosbase in a6
clr.l d2 ;no external control
move.l windowhd,d3 ;window to execute in;CLI
jsr execute(a6) ;And execute it.
----------------------------------------------
The execute command needs the RUN command in the C-directory.
The following routine closes the Dos.library again
and gets you right back to where you started from...
----------------------------------------------
Closelibrary: move.l execbase,a6
move.l dosbase,a1
jsr closelib(a6)
rts
----------------------------------------------
This is the place where you store your command(s),
or a startup-sequence for that matter.
----------------------------------------------
Command1:
dc.b "intro",00
even ;Words at odd adresses are not allowed!
----------------------------------------------
dosname: dc.b"dos.library",0 ;Name of library to be opened
even
----------------------------------------------
dosbase: dc.l 0 ;The base of the library
even
----------------------------------------------
windowhd: dc.l 0 ;This is 0-CLI window
even
----------------------------------------------
The execute command is quite nice if you want to load programs.
A loader for a bootmenu can be made in this way.Just put a code
in the memory when you exit the bootmenu,make a routine in the loader
that puts different commands in d1,do the execute stuff,and ready is
your loader....
That's all for now....
ROGER from VIRUS